package weaver.workflow.cms.xiao.utils;


import java.util.HashMap;
import java.util.Map;

/**
 * @author XiaoBokang
 * @create 2021/8/23 16:34
 */

public class RequestBaseInfo{

    private String type;
    private String url;
    private Object params;
    private Map<String,String > headers;

    private static final Map<String,String > HEADER_NORMAL = new HashMap<>();
    private static final Map<String,Object > PARAMS_NORMAL = new HashMap<>();

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Object getParams() {
        return params;
    }

    public void setParams(Object params) {
        this.params = params;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    public static RequestBaseInfo create(String type, String url){
        return create(type,url,HEADER_NORMAL,PARAMS_NORMAL);
    }

    public static RequestBaseInfo create(String type, String url, Map<String, String> headers){
        return create(type,url,headers,PARAMS_NORMAL);
    }

    public static RequestBaseInfo create(String type, String url, Map<String, String> headers, Object params){
        RequestBaseInfo requestInfo =  new RequestBaseInfo();
        requestInfo.setType(type.toUpperCase());
        requestInfo.setUrl(url);
        requestInfo.setParams(params);
        requestInfo.setHeaders(headers);
        return requestInfo;
    }
}
